﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//public partial class Theme_index_OpenNews :PowerCreator.LMS.Web.Base.WebBasePage    by windbell↓
public partial class Theme_index_OpenNews : System.Web.UI.Page
{
    PowerCreator.LMS.Web.CMS.New opNews = new PowerCreator.LMS.Web.CMS.New();

    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string newsid = Request.QueryString["NewsID"].ToString();
            ViewState["NewsID"] = newsid;
            //RoundNews();
            BinderPageData();
        }
    }
    /* by windbell↓
    protected override void InitPage()
    {
        base.InitPage();
    }
     * */


    //private void RoundNews()
    //{
    //    //随机推荐
    //    string search = "NewState=1";
    //    string orderBy = " NewID() ";
    //    DataTable dt = opNews.Query(search, orderBy, PowerCreator.LMS.Web.Config.WebConfig.PageSize, 1);
    //    rpt_News.DataSource = dt;
    //    rpt_News.DataBind();
    //}
    private void BinderPageData()
    {
        PowerCreator.LMS.CMS.Entity.VOTNew voNews = opNews.Load(int.Parse(ViewState["NewsID"].ToString()));
        if (voNews.NewID > 0)
        {
            this.Title = voNews.NewTitle;
            if (voNews.NewPictureUrl != null)
            {
                if (voNews.NewPictureUrl.Length > 3)
                {
                    //tr_Pic.Visible = true;
                    lbl_pic.Text = "<img src=\"" + voNews.NewPictureUrl + "\" alt=\"" + voNews.NewTitle + "\" />";
                }
                //else
                //    tr_Pic.Visible = false;
            }
            //else
            //    tr_Pic.Visible = false;
            lbl_Title.Text = voNews.NewTitle;
            lbl_TimePublish.Text = voNews.NewPublishTime.ToString();
            lbl_countnum.Text =(voNews.NewClickNum+1).ToString();
            lit_NewsContent.Text = voNews.NewContent;
            voNews.NewClickNum += 1;
            opNews.Update(voNews);
        }
    }

}
